package com.ruoyi.healthCard.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.healthCard.domain.TBizPackagePhysicalItem;
import com.ruoyi.healthCard.service.ITBizPackagePhysicalItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 套餐项目关联Controller
 * 
 * @author ruoyi
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/health/itemPackage")
public class TBizPackagePhysicalItemController extends BaseController
{
    @Autowired
    private ITBizPackagePhysicalItemService tBizPackagePhysicalItemService;

    /**
     * 查询套餐项目关联列表
     */
    @PreAuthorize("@ss.hasPermi('health:itemPackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBizPackagePhysicalItem tBizPackagePhysicalItem)
    {
        startPage();
        List<TBizPackagePhysicalItem> list = tBizPackagePhysicalItemService.selectTBizPackagePhysicalItemList(tBizPackagePhysicalItem);
        return getDataTable(list);
    }

    /**
     * 导出套餐项目关联列表
     */
    @PreAuthorize("@ss.hasPermi('health:itemPackage:export')")
    @Log(title = "套餐项目关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBizPackagePhysicalItem tBizPackagePhysicalItem)
    {
        List<TBizPackagePhysicalItem> list = tBizPackagePhysicalItemService.selectTBizPackagePhysicalItemList(tBizPackagePhysicalItem);
        ExcelUtil<TBizPackagePhysicalItem> util = new ExcelUtil<TBizPackagePhysicalItem>(TBizPackagePhysicalItem.class);
        util.exportExcel(response, list, "套餐项目关联数据");
    }

    /**
     * 获取套餐项目关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:itemPackage:query')")
    @GetMapping(value = "/{bizpackagePhysicalItemId}")
    public AjaxResult getInfo(@PathVariable("bizpackagePhysicalItemId") Long bizpackagePhysicalItemId)
    {
        return success(tBizPackagePhysicalItemService.selectTBizPackagePhysicalItemByBizpackagePhysicalItemId(bizpackagePhysicalItemId));
    }

    /**
     * 新增套餐项目关联
     */
    @PreAuthorize("@ss.hasPermi('health:itemPackage:add')")
    @Log(title = "套餐项目关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBizPackagePhysicalItem tBizPackagePhysicalItem)
    {
        return toAjax(tBizPackagePhysicalItemService.insertTBizPackagePhysicalItem(tBizPackagePhysicalItem));
    }

    /**
     * 修改套餐项目关联
     */
    @PreAuthorize("@ss.hasPermi('health:itemPackage:edit')")
    @Log(title = "套餐项目关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBizPackagePhysicalItem tBizPackagePhysicalItem)
    {
        return toAjax(tBizPackagePhysicalItemService.updateTBizPackagePhysicalItem(tBizPackagePhysicalItem));
    }

    /**
     * 删除套餐项目关联
     */
    @PreAuthorize("@ss.hasPermi('health:itemPackage:remove')")
    @Log(title = "套餐项目关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bizpackagePhysicalItemIds}")
    public AjaxResult remove(@PathVariable Long[] bizpackagePhysicalItemIds)
    {
        return toAjax(tBizPackagePhysicalItemService.deleteTBizPackagePhysicalItemByBizpackagePhysicalItemIds(bizpackagePhysicalItemIds));
    }
}
